import { get, post } from '../../request'
export interface Pwd {
  loginName: string
  password: string
  captchaCode: string
  captchaId: string
}
export interface Sms {
  smsCode: string
  cellphone: string
}

const ns = '/auth' // namespace

export const authApi = {
  loginPwd: (data: Pwd) => {
    return post({ url: `${ns}/login/pwd`, data })
  },
  loginSms: (data: Sms) => {
    return post({ url: `${ns}/login/sms`, data })
  },
  profile: () => {
    return get({ url: `${ns}/profile` }, false)
  },
  sendSmsCode: (cellphone: string) => {
    return post({ url: `${ns}/sms/code`, data: { cellphone } })
  },
  getCaptchaCode: () => {
    return get({ url: `${ns}/captcha/code` })
  },
  logout: () => {
    return post({ url: '/logout' })
  },
  ssoVerifyCode: (code: string, redirectUri: string) => {
    return post({ url: `${ns}/sso/verify-code`, data: { code, redirectUri } })
  }
}
